#include "TextBox.h"

namespace game
{

//TextBox::TextBox(const sf::Text * name,const sf::Text * desc, sf::Vector2u pos, sf::Vector2u size)
//{
//	_hidden = false;
//	_name = name;
//	_name.setPosition(sf::Vector2f(pos.x,pos.y));
//	//_desc = desc;
//	_rect = sf::RectangleShape(sf::Vector2f(size.x,size.y));
//	_rect.setPosition(sf::Vector2f(pos.x,pos.y));
//
//	_rect.setOutlineColor(sf::Color(33,233,22));
//	_rect.setFillColor(sf::Color(144,33,223));
//	_rect.setOutlineThickness(1);
//}

TextBox::TextBox(std::string name,std::string desc,int size, sf::Vector2u pos, sf::Vector2u rsize)
{
	_hidden = false;
	_font = new sf::Font(sf::Font::getDefaultFont()); 
	_name = new sf::Text(name,*_font);
	_name->setCharacterSize(size);
	_name->setPosition(sf::Vector2f(pos.x,pos.y));
	//_desc = sf::Text(desc);
	//_desc.setCharacterSize(size);
	_rect = new sf::RectangleShape(sf::Vector2f(rsize.x,rsize.y));
	_rect->setPosition(sf::Vector2f(pos.x,pos.y));

	_rect->setOutlineColor(sf::Color(33,233,22));
	_rect->setFillColor(sf::Color(144,33,223));
	_rect->setOutlineThickness(1);
}

void TextBox::setPos(sf::Vector2u pos)
{
	_rect->setPosition(sf::Vector2f(pos.x,pos.y));
	_name->setPosition(sf::Vector2f(pos.x,pos.y));
}
void TextBox::setName(std::string s)
{
	_name->setString(s);
}
std::string TextBox::getName()
{
	return _name->getString();
}
sf::Vector2u TextBox::getPos()
{
	sf::Vector2f pos = _rect->getPosition();
	return sf::Vector2u((unsigned int)pos.x,(unsigned int)pos.y);
}
sf::Vector2u TextBox::getSize()
{
	sf::Vector2f size = _rect->getSize();
	return sf::Vector2u((unsigned int)size.x,(unsigned int)size.y);
}
void TextBox::hide()
{
	_hidden = true;
}

void TextBox::show()
{
	_hidden = false;
}

void TextBox::draw(sf::RenderWindow  &p)
{
	if (!_hidden)
	{
		p.draw(*_rect);
		p.draw(*_name);
	}
}

//TextBox::~TextBox(void)
//{
//
//}

}